# -*- coding: utf-8 -*-
import pymysql.cursors
import sys
from config import *
reload(sys)
sys.setdefaultencoding( "utf-8" )


def createTingshu(data):
	conn= pymysql.connect(
	        host=env('DB_HOST'),
	        port = env('DB_PORT'),
	        user=env('DB_USER'),
	        passwd=env('DB_PASSWORD'),
	        charset='utf8mb4',
	        db =env('DB_NAME'),
	        )
	cur = conn.cursor()
	print data['audio_price']
	#cur.execute("insert into mojia_article_tingshu(title,audio_price,brief,image_original,image_local,image,content,audio_original,audio_local,audio,datetime,created_at) values(data['title'],data['audio_price'],data['brief'],data['image_original'],data['image_local'],data['image'],data['content'],data['audio_original'],data['audio_local'],data['audio'],data['datetime'],data['created_at'])")
	sql = "INSERT INTO `mojia_article_tingshu` (title,duration,brief,audio_price,image_original,image_local,image,content,audio_original,audio_local,audio,datetime,created_at) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s, %s,%s, %s)"
	cur.execute(sql, (data['title'],data['duration'],data['brief'],data['audio_price'],data['image_original'],data['image_local'],data['image'],data['content'],data['audio_original'],data['audio_local'],data['audio'],data['datetime'],data['created_at']))
	conn.commit()
	conn.close()
	cur.close()